package com.communal.web.form.cr;

import net.sf.ezmorph.bean.MorphDynaBean;
import net.sf.json.JSONObject;

import com.communal.model.cr.CRRent;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
public class CRRentForm extends CRForm{

	private final String TARIF_ID = "tarifId";
	private Integer tarifId;
	
	/**
	 * Constructor from JSON data for {@link CRRentForm} <br>
	 * @param p_data - JSON data
	 */
	public CRRentForm(Object p_data) {
		super( p_data, true );
		JSONObject jsonObject = JSONObject.fromObject(p_data);
		MorphDynaBean bean = (MorphDynaBean) JSONObject.toBean(jsonObject);
		tarifId = (Integer) bean.get(TARIF_ID);
	}

	/**
	 * Constructor for {@link CRRentForm} from rent entity <br>
	 * @param p_communalRecord {@link CRRent}
	 */
	public CRRentForm(CRRent p_rent, String p_monthYear) {
		super( p_rent, p_monthYear );
		tarifId= p_rent.getTarif().getId();
	}

	/**
	 * Returns tarif id <br>
	 * @return {@link Integer};
	 */
	public Integer getTarifId() {
		return tarifId;
	}

	/**
	 * Sets tarif id <br>
	 * @param p_tarifId - {@link Integer};
	 */
	public void setTarifId(Integer p_tarifId) {
		tarifId = p_tarifId;
	}
}
